$(document).ready(function() {

    queryGoodsByKeywords();

});


var queryGoodsByKeywords = function () {

    var keywords = getUrlParms("keywords");

    $.ajax({

        url: "http://localhost:8002/goods/searchGoods/"+keywords,
        type: "GET",
        async: true,
        data: null ,
        dataType: "json",
        success: function (data) {
            console.log(data)
            if (data.code===201) {
                for (var i = 0; i < data.data.length; i++) {

                    var goods = data.data[i];
                    $("#main-center").append(
                        "<div class=\"mingxing fl mb20\" style=\"border:2px solid #fff;width:230px;cursor:pointer;\" onmouseout=\"this.style.border='2px solid #fff'\" onmousemove=\"this.style.border='2px solid red'\">" +
                        "<div class=\"sub_mingxing\"><a href="+goods.buyURL+" target=\"_blank\"><img src="+goods.picture+" alt=\"\"></a></div>" +
                        "<div class=\"pinpai\"><a href=\"./goodsDetail.html\" target=\"_blank\">"+goods.skuName+"</a></div>" +
                        "<div class=\"youhui\">"+goods.spuIntro+"</div>" +
                        "<div class=\"jiage\">"+goods.goodsPrice+"元</div>" +
                        "</div>"
                    )
                }

            }else{
                layer.msg("加载失败!");
            }
        },
        error: function () {
            layer.msg("加载失败!");
        }


    })

    
};


